package dao.Imp;

import dao.CollegeDao;
import dao.JDBC;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;

public class CollegeDaoImp implements CollegeDao {
    @Override
    public boolean login(String user, String pwd) {
        Connection con=null;
        PreparedStatement pstmt=null;
        ResultSet rs=null;
        try{
            con= JDBC.getConnection();
            String sql="select *from college where user=? and pwd=?";
            pstmt=con.prepareStatement(sql);
            pstmt.setString(1, user);
            pstmt.setString(2, pwd);
            rs= pstmt.executeQuery();
            if (rs.next()){
                return true;
            }
        }catch (Exception e){
            e.printStackTrace();
        }finally {
            JDBC.release(rs,pstmt,con);
        }
        return false;
    }
}
